Skip to content

Fix workspace restore idempotency and strict RPC parsing#470

Closed
jmcte wants to merge 2 commits intoDimillian:mainfrom
jmcte:jmcte/fix-workspace-restore-rpc-tauri
Closed

Fix workspace restore idempotency and strict RPC parsing#470
jmcte wants to merge 2 commits intoDimillian:mainfrom
jmcte:jmcte/fix-workspace-restore-rpc-tauri

Conversation

@jmcte
Copy link
Contributor

@jmcte jmcte commented Feb 20, 2026

Summary

  • Fix workspace restore marker lifecycle so failed restoreWorkspace attempts are not treated as permanently restored.
  • Make local workspace connect idempotent/race-safe so concurrent calls do not spawn duplicate sessions.
  • Tighten optional RPC parsing for optional u32 and string-array inputs to reject malformed values.
  • Centralize Tauri invoke error handling and standardize missing-bridge fallback behavior (listWorkspaces returns [], other wrappers return explicit bridge errors).
  • Add regression tests for restore flow, Tauri wrapper behavior, and strict parser errors.

Related issue

Validation

  • npm run test -- src/features/workspaces/hooks/useWorkspaceRestore.test.tsx src/services/tauri.test.ts
  • cd src-tauri && cargo check
  • cd src-tauri && cargo test parse_optional
  • npm run typecheck (currently fails in this environment due missing optional external typings: @tauri-apps/plugin-notification, vscode-material-icons).

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0eb580be10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 35 to +36
await listThreadsForWorkspace(workspace);
restoredWorkspaces.current.add(workspace.id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard workspace restore while the first attempt is running

restoredWorkspaces is now updated only after connectWorkspace and listThreadsForWorkspace resolve, so any re-render before that completion will schedule another restore for the same workspace. Because this effect re-runs on changing dependencies (workspaces and callback identities), startup renders can fan out parallel restore calls, which duplicates thread-list RPCs and can race thread state updates; keep retry behavior but add an in-flight guard (or mark before await and clear on failure).

Useful? React with 👍 / 👎.

}),
_ => None,
},
_ => Err(format!("invalid `{key}`")),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat null RPC params as absent for optional u32 parsing

The transport layer uses Value::Null when a JSON-RPC request omits params (src-tauri/src/bin/codex_monitor_daemon/transport.rs), but this parser now returns Err for any non-object, so methods with only optional numeric inputs (like local_usage_snapshot) fail with invalid \days`when callers send no params. This is a backward-incompatible regression from the previous behavior where omitted optional values were accepted asNone`.

Useful? React with 👍 / 👎.

# Conflicts:
#	src/services/tauri.ts
@Dimillian
Copy link
Owner

Completely break sidebar loading state, make those changed one by one and test the app

@Dimillian Dimillian closed this Feb 20, 2026
@jmcte jmcte deleted the jmcte/fix-workspace-restore-rpc-tauri branch February 20, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants